//
//  withdrawalViewController.m
//  Edumap
//
//  Created by 辰领科技 on 16/7/22.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "withdrawalViewController.h"


@interface withdrawalViewController ()


@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UITableView *tableView;

@property (strong, nonatomic) IBOutlet UITextField *moneyTextField;//提现金额

@property (strong, nonatomic) IBOutlet UITextField *nameTextField;//户名
@property (strong, nonatomic) IBOutlet UITextField *accountTextField;//账号
@property (strong, nonatomic) IBOutlet UITextField *typeTextField;//开户银行
@property (strong, nonatomic) IBOutlet UIButton *confirmButton;

@end

@implementation withdrawalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
}

- (void)initViewLayout {
    [self adaptiveViewLayout:self.view];
    self.view.backgroundColor = [UIColor colorWithWhite:0.957 alpha:1.000];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    _scroview.contentSize = flexibleSize(CGSizeMake(0, 505), NO);
    _confirmButton.layer.cornerRadius = 5*VerticalRatio();
    
}


- (IBAction)back:(id)sender {
    [self backBtn];
}

#pragma mark - 确认
- (IBAction)confirm:(id)sender {
    
    if (_moneyTextField.text.length==0) {
        [CWHUDTips showTips:_moneyTextField.placeholder];
        return;
    }
    if (_nameTextField.text.length==0) {
        [CWHUDTips showTips:_nameTextField.placeholder];
        return;
    }
    if (_accountTextField.text.length==0) {
        [CWHUDTips showTips:_accountTextField.placeholder];
        return;
    }
    if (_typeTextField .text.length==0) {
        [CWHUDTips showTips:_typeTextField.placeholder];
        return;
    }
    
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][@"userId"] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][@"userId"] forKey:@"mewiMemberId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    
    [dic setObject:_moneyTextField.text forKey:@"mewiAmount"];
    [dic setObject:_nameTextField.text forKey:@"mewiAccountName"];
    [dic setObject:_accountTextField.text forKey:@"mewiAccountNo"];
    [dic setObject:_typeTextField.text forKey:@"mewiAccountBank"];
    
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:JY_applyToCash withHttpType:@"POST" withTag:JY_JY_applyToCash];

}


#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if (tag==JY_JY_applyToCash) {
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            [self backBtn];
        }
    }
    
}

-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    [self dismissWaitDialog];
}


@end
